﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Modeling_Sub_Pages_NewsPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UniversityDatabaseManagerment udm = new UniversityDatabaseManagerment();
        
        try
        {
            if (udm.createConnection() != null)
            {
                ProductDataList2.DataSource = udm.showNewCoursesNotEndRegist(udm.createConnection());
                ProductDataList2.DataBind();       
            }
            else
            {
                Response.Redirect("~/ErrorPage.aspx");
            }
        }
        catch (Exception)
        {
            Response.Redirect("~/ErrorPage.aspx");
        }
    }
    protected void ProductDataList2_PagePropertiesChanged(object sender, EventArgs e)
    {
        ProductDataList2.DataBind(); 
    }
    protected void ProductDataList2_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        Label lblMonday = (Label)e.Item.FindControl("lblMonday");
        Label lblTuesday = (Label)e.Item.FindControl("lblTuesday");
        Label lblWednesday = (Label)e.Item.FindControl("lblWednesday");
        Label lblThursday = (Label)e.Item.FindControl("lblThursday");
        Label lblFriday = (Label)e.Item.FindControl("lblFriday");
        Label lblSaturday = (Label)e.Item.FindControl("lblSaturday");
        Label lblSunday = (Label)e.Item.FindControl("lblSunday");

        if (lblMonday.Text.Equals("True"))
        {
            lblMonday.BackColor = System.Drawing.Color.Gray;
            lblMonday.ForeColor = System.Drawing.Color.White;
            lblMonday.Text = "M";
        }
        else 
        {
            lblMonday.Text = "M";
        }

        if (lblTuesday.Text.Equals("True"))
        {
            lblTuesday.BackColor = System.Drawing.Color.Gray;
            lblTuesday.ForeColor = System.Drawing.Color.White;
            lblTuesday.Text = "T";
        }
        else
        {
            lblTuesday.Text = "T";
        }

        if (lblWednesday.Text.Equals("True"))
        {
            lblWednesday.BackColor = System.Drawing.Color.Gray;
            lblWednesday.ForeColor = System.Drawing.Color.White;
            lblWednesday.Text = "W";
        }
        else
        {
            lblWednesday.Text = "W";
        }

        if (lblThursday.Text.Equals("True"))
        {
            lblThursday.BackColor = System.Drawing.Color.Gray;
            lblThursday.ForeColor = System.Drawing.Color.White;
            lblThursday.Text = "T";
        }
        else
        {
            lblThursday.Text = "T";
        }

        if (lblFriday.Text.Equals("True"))
        {
            lblFriday.BackColor = System.Drawing.Color.Gray;
            lblFriday.ForeColor = System.Drawing.Color.White;
            lblFriday.Text = "F";
        }
        else
        {
            lblFriday.Text = "F";
        }

        if (lblSaturday.Text.Equals("True"))
        {
            lblSaturday.BackColor = System.Drawing.Color.Gray;
            lblSaturday.ForeColor = System.Drawing.Color.White;
            lblSaturday.Text = "S";
        }
        else
        {
            lblSaturday.Text = "S";
        }

        if (lblSunday.Text.Equals("True"))
        {
            lblSunday.BackColor = System.Drawing.Color.Gray;
            lblSunday.ForeColor = System.Drawing.Color.White;
            lblSunday.Text = "S";
        }
        else
        {
            lblSunday.Text = "S";
        }
    }
}